import axios from '@/libs/api.request'

export const getTableData = () => {
  return axios.request({
    url: 'get_table_data',
    method: 'get'
  })
}

export const getDragList = () => {
  return axios.request({
    url: 'get_drag_list',
    method: 'get'
  })
}

export const errorReq = () => {
  return axios.request({
    url: 'error_url',
    method: 'post'
  })
}

export const saveErrorLogger = info => {
  return axios.request({
    url: 'save_error_logger',
    data: info,
    method: 'post'
  })
}

export const uploadImg = formData => {
  return axios.request({
    url: 'image/upload',
    data: formData
  })
}

export const getProductlist = searchData => {
    return axios.request({
        url: '/admin/product/List',
        method: 'post',
        data:searchData
    })
}

export const delProduct = formData => {
    return axios.request({
        url: '/admin/product/delete/'+formData,
        method: 'get'
    })
}

export const getProduct = formData => {
    return axios.request({
        url: '/admin/product/get/'+formData,
        method: 'get'
    })
}

export const editProduct = formData => {
    return axios.request({
        url: '/admin/product/edit',
        method: 'post',
        data:formData
    })
}

export const addProduct = formData => {
    return axios.request({
        url: '/product/edit',
        method: 'post',
        data:formData
    })
}
//��ȡ��ҵ
export const getIndustryInfo = formData => {
    return axios.request({
        url: '/product/edit',
        method: 'post',
        data:formData
    })
}
//获取产品分类列表
export const getStoreCategoryList = formData => {
    formData=urlEncode(formData);
    formData=formData.substr(1);
    return axios.request({
        url: '/admin/store/category/getlist',
        method: 'post',
        data:formData
    })
}
//获取产品分类
export const getStoreCategoryInfo = formData => {
    formData=urlEncode(formData);
    formData=formData.substr(1);
    return axios.request({
        url: '/admin/store/category/GetModel',
        method: 'post',
        data:formData
    })
}
//获取行业列表
export const getIndustryList = () => {
    return axios.request({
      url: 'http://192.168.2.31:8080/rrk-supplier-ui/admin/store/industry/getlist',
      method: 'post'
    })
}
//修改产品分类
export const editStoreCategory = formData => {
    return axios.request({
        url: '/admin/store/category/Update',
        method: 'post',
        data:formData
    })
}
//添加产品分类
export const addStoreCategory = formData => {
    debugger;
    return axios.request({
        url: '/admin/store/category/Add',
        method: 'post',
        data:formData
    })
}
//删除产品分类
export const delStoreCategoryInfo = formData => {
    formData=urlEncode(formData);
    formData=formData.substr(1);
    return axios.request({
        url: '/admin/store/category/del',
        method: 'post',
        data:formData
    })
}
//批量删除产品分类
export const delStoreCategoryList = formData => {
    formData=urlEncode(formData);
    formData=formData.substr(1);
    return axios.request({
        url: '/admin/store/category/delList',
        method: 'post',
        data:formData
    })
}
//获取分类属性列表
export const getAttributeList = formData => {
    formData=urlEncode(formData);
    formData=formData.substr(1);
    return axios.request({
        url: '/admin/store/category/attribute/get',
        method: 'post',
        data:formData
    })
}
//获取分类属性详情
export const GetAttributeModel = formData => {
    formData=urlEncode(formData);
    formData=formData.substr(1);
    return axios.request({
        url: '/admin/store/category/attribute/GetModel',
        method: 'post',
        data:formData
    })
}
//修改产品分类属性详情
export const editAttributeValue = formData => {
    return axios.request({
        url: '/admin/store/category/attribute/edit',
        method: 'post',
        data:formData
    })
}
//添加产品分类属性详情
export const addAttributeValue = formData => {
    debugger;
    return axios.request({
        url: '/admin/store/category/attribute/Add',
        method: 'post',
        data:formData
    })
}

//获取分类属性组列表
export const getAttributeGroupsList = formData => {
    formData=urlEncode(formData);
    formData=formData.substr(1);
    return axios.request({
        url: '/admin/store/category/attribute_groups/GetList',
        method: 'post',
        data:formData
    })
}
//获取分类属性组详情
export const getAttributeGroupsModel = formData => {
    debugger;
    formData=urlEncode(formData);
    formData=formData.substr(1);
    return axios.request({
        url: '/admin/store/category/attribute_groups/GetModel',
        method: 'post',
        data:formData
    })
}
//修改产品分类属性组详情
export const editAttributeGroups = formData => {
    return axios.request({
        url: '/admin/store/category/attribute_groups/Edit',
        method: 'post',
        data:formData
    })
}
//添加产品分类属性组详情
export const addAttributeGroups = formData => {
    debugger;
    return axios.request({
        url: '/admin/store/category/attribute_groups/Add',
        method: 'post',
        data:formData
    })
}

var urlEncode = function (param, key, encode) {  
    if(param==null) return '';  
    var paramStr = '';  
    var t = typeof (param);  
    if (t == 'string' || t == 'number' || t == 'boolean') {  
      paramStr += '&' + key + '=' + ((encode==null||encode) ? encodeURIComponent(param) : param);  
    } else {  
      for (var i in param) {  
        var k = key == null ? i : key + (param instanceof Array ? '[' + i + ']' : '.' + i);  
        paramStr += urlEncode(param[i], k, encode);  
      }  
    } 
    return paramStr;  
  }; 

//获取供应商订单列表
export const getOrderInfoList = formData => {
    formData=urlEncode(formData);
    formData=formData.substr(1);
    var url='http://localhost:8141/admin/supplier/order/list?'+formData;
    return axios.request({
        url: url,
        method: 'get'
    })
}
